unit uAsync;

interface

uses
  SysUtils, Classes, Windows, uDZSocket, uCxtTypes, uCxtPackage, uCxtNet;

type
  TAsyncContext = object
    Connection: TCxtConnection;
    Request: TRequestPackage;
    Response: TResponsePackage;
  end;
  PAsyncContext = ^TAsyncContext;

function AllocAsyncContext(Conn: TCxtConnection; Request: TRequestPackage;
  Response: TResponsePackage): PAsyncContext; inline;

procedure DeallocAsyncContext(pContext: PAsyncContext); inline;

implementation

function AllocAsyncContext(Conn: TCxtConnection; Request: TRequestPackage;
  Response: TResponsePackage): PAsyncContext;
begin
  New(Result);
  Result.Connection := Conn;
  Result.Request := Request;
  Result.Response := Response;
end;

procedure DeallocAsyncContext(pContext: PAsyncContext);
begin
  pContext.Request.Free;
  pContext.Response.Free;
  pContext.Connection.Release;
  Dispose(pContext);
end;

end.
